php编写简单的文章发布程序
$start); $info=$query-get()-result_array(); $this-myclass-p($info); echo $this-pagination-create_links(); //echo base_url(abc/def); } protected function _page($total_rows。
不行); //p($val); return true; } function article_mod(){ $this-load-library(form_validation); //开始设置验证规则 //set_message可以传一个一维数组 $chinesetips=$this-tips; $this-form_validation-set_message($chinesetips); $this-form_validation-set_rules(title,$data); if($st){ echo 数据插入成功!; echo 新的id为:.$this-db-insert_id(); } //echo get_magic_quotes_gpc(); }else{ echo 表单验证失败!; echo br /; echo validation_errors(); } } function article_add_viewer(){ $this-load-helper(url); $this-load-view(article_add); } function article_links(){ $addr=site_url(article/article_mod_viewer/19); echo a href=$addr修改19/a; } function article_mod_viewer($id){ if($id==){ echo 没有传递参数; exit; } $this-load-helper(url); //从数据库中查出来 $query=$this-db-select()-from(article)-where(id,18,required); $this-form_validation-set_rules(tag,请输入其它名称!,$id)-get(); $info=$query-row_array(); print_r($info); $this-load-view(article_mod。
PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=21 ; article.php ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 ?php class Article extends CI_Controller{ public $tips; function __construct(){ parent::__construct(); //加载我自己的类库 $this-load-library(myclass); $this-load-database(); $this-load-helper(url); $this-tips=array( required= [%s] 是必须填写的!,trim|required|min_length[6]|max_length[12]|callback_abc); $this-form_validation-set_rules(content。
5)-select(id, `content` mediumtext NOT NULL,内容,desc)-limit(4)-get(); $info=$query-result_array();//当然你可以用result() $this-myclass-p($info); echo 第一条记录的标题:.$info[0][title]; echo br /; echo 第二条记录的标题:.$info[1][id]; echo br /; echo 表article中共有这么些记录:.$this-db-count_all(article); echo br /; echo 本次共查询出这么些条记录:.$query-num_rows(); } function article_page($page=1){ /////////////////////////////////// $config=array(); //第一步查询出总记录数 $this-load-database(); $config[total_rows]=$this-db-select(*)-from(article)-count_all_results(); //每页记录数 $config[per_page]=5; //基础url $this-load-helper(url); $config[base_url]=site_url(article/article_page); //显示的链接数 $config[num_links]=100; //在地址栏显示当前页码 $config[use_page_numbers]=true; //定义首页 $config[first_link]=首页; //定义末页 $config[last_link]=尾页; //上一页 $config[prev_link]=上一页; //下一页 $config[next_link]=下一页; //把分页包起来 $config[full_tag_open]=p; $config[full_tag_close]=/p; //第二步加载类库 $this-load-library(pagination); $this-pagination-initialize($config); echo $this-pagination-create_links(); ///////////////////////////////////// $page=$page?intval($page):1; $start=($page-1)*$config[per_page]; $query=$this-db-select(*)-from(article)-limit($config[per_page], `views` int(11) NOT NULL,required); if($this-form_validation-run()==true){ echo 表单验证成功!; print_r($this-input-post()); $data=$this-input-post(); $id=$data[id]; unset($data[id]); unset($data[Submit]); $data[add_time]=date(Y-m-d H:i:s); $data[views]=0; //p($data); $st=$this-db-where(id,trim|required|is_unique[article.title]|min_length[6]|max_length[12]); $this-form_validation-set_rules(content, -- 表的结构 `yi_article` -- ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 CREATE TABLE IF NOT EXISTS `yi_article` ( `id` int(11) unsigned NOT NULL auto_increment。
title)-from(article)-order_by(id。
$id)-update(article。
$id)-delete(article); $st=$this-db-affected_rows(); echo $st; if($st){ echo 数据删除成功!; }else{ echo 数据删除失败!; } } } ? article_add.php ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN html xmlns= xml:lang=en lang=en head meta http-equiv=content-type content=text/html; charset=utf-8 / meta name=author content= / title无标题 1/title /head body form name=form1 action=?php echo site_url(article/article_add)? method=post 标题:input name=title type=text value= /br / 内容:input name=content type=text value= /br / 添加人:input name=add_man type=text value= /br / 添加时间:系统自动记录br / 状态:input name=tag type=radio value=1 /显示 input name=tag type=radio value=0 /隐藏br / input type=submit name=Submit value=提交 / /form /body /html article_mod.php ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN html xmlns= xml:lang=en lang=en head meta http-equiv=content-type content=text/html; charset=utf-8 / meta name=author content= / title无标题 1/title /head body form name=form1 action=?php echo site_url(article/article_mod)? method=post 标题:input name=title type=text value=?php echo $title;? /br / 内容:input name=content type=text value=?php echo $content? /br / 添加人:input name=add_man type=text value=?php echo $add_man;? /br / 添加时间:系统自动记录br / 状态:input name=tag type=radio value=1 ?php if($tag==1)echo checked;? /显示 input name=tag type=radio value=0 ?php if($tag==0)echo checked;? /隐藏br / input type=submit name=Submit value=提交 / input type=hidden value=?php echo $id;? name=id / /form /body /html , `add_time` datetime NOT NULL,$start); $info=$query-get()-result_array(); return $info; } function article_add(){ $this-load-library(form_validation); //开始设置验证规则 //set_message可以传一个一维数组 $chinesetips=$this-tips; $this-form_validation-set_message($chinesetips); /* $this-form_validation-set_message(required,required); $this-form_validation-set_rules(tag。
状态,请输入其它名称!); $this-form_validation-set_message(min_length,内容。
标题, min_lenght= [%s] 最小长度为 [%s]。
19); $this-db-where_in(id,状态,标题,$data); if($st){ echo 数据修改成功; }else{ echo 数据修改失败; } }else{ echo 表单验证失败!; echo br /; echo validation_errors(); } } function article_del($id=){ if($id==){ //exit(请传id); } $id=array(17, max_length=[%s] 最大长度为 [%s] ); } function index(){ echo 这里是文章的首页; echo br /; //加载url辅助函数 $this-load-helper(url); $addr=site_url(article/article_list); echo a href=$addr查看文章/a; $addr=site_url(article/article_page); echo a href=$addr查看分页/a; } function article_list(){ echo 这里是文章列表; //加载数据库模型 //$this-load-model(article_model); //$this-article_model-index(); //读取所有的文章 $this-load-database(); echo br /; $query=$this-db-where(id , [%s] 最大长度为 [%s]); */ $this-form_validation-set_rules(title, [%s] 最小长度为 [%s]); $this-form_validation-set_message(max_length, 此 [%s] 已经存在, [%s] 是必须填写的!); $this-form_validation-set_message(is_unique, is_unique=此 [%s] 已经存在,required); if($this-form_validation-run()==true){ echo 表单验证成功!; print_r($this-input-post()); $data=$this-input-post(); unset($data[Submit]); $data[add_time]=date(Y-m-d H:i:s); $data[views]=0; $st=$this-db-insert(article,$per_page, `title` varchar(256) NOT NULL,$info); } function abc($val){ $this-form_validation-set_message(abc, `add_man` varchar(20) NOT NULL, `tag` tinyint(4) NOT NULL。
$base_url){ /////////////////////////////////// $config=array(); //第一步查询出总记录数 //$this-load-database();//// $config[total_rows]=$total_rows; //每页记录数 $config[per_page]=$per_page; //基础url $this-load-helper(url);//// $config[base_url]=site_url($base_url); //显示的链接数 $config[num_links]=100; //在地址栏显示当前页码 $config[use_page_numbers]=true; //定义首页 $config[first_link]=首页; //定义末页 $config[last_link]=尾页; //上一页 $config[prev_link]=上一页; //下一页 $config[next_link]=下一页; //把分页包起来 $config[full_tag_open]=p; $config[full_tag_close]=/p; //第二步加载类库 $this-load-library(pagination); $this-pagination-initialize($config); return $this-pagination-create_links(); ///////////////////////////////////// } function page($page=1){ $config[per_page]=5; $page=$page?intval($page):1; $start=($page-1)*$config[per_page]; $query=$this-db-select(*)-from(article)-limit($config[per_page],。
相关热词:
本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!
本文地址: https://v30.fanwenzhu.com/jiaob/php/10898.shtml
相关文章
热门TAG
win10 ecshop 主机 阿里云 解决 配置 C# C++ 解析 SQL语句 命令 Go语言 方法 CSS3 HTML5 CSS win7 MSSQL 服务器配置 IIS7.5 IIS7 IIS6 IIS CentOS 7 Linux oracle数据库 oracle phpcms discuz discuz教程最新文章
-
9. PHPDebugbar PHPDebugbar也是
时间:2021-01-13
-
10个免费的PHP编辑器/开拓
时间:2021-01-13
-
2019年最好用的10个php开拓
时间:2021-01-13
-
在casescheme:下面加入 retu
时间:2021-01-13
-
php实现将wav文件转换成图
时间:2021-01-11
-
PHP判断是否为空的几个函
时间:2021-01-11
-
护卫神php套件 php版本升级
时间:2021-01-10
-
浅析iis7.5安装配置php环境
时间:2021-01-10
热门文章
-
2019年最好用的10个php开发工具推荐
时间:2020-12-23
-
PHP的伪随机数与真随机数详解
时间:2021-01-04
-
PHP中把错误日志保存在系统日志中(Win
时间:2020-12-29
-
9. PHPDebugbar PHPDebugbar也是一款PHP调试器
时间:2021-01-13
-
10个免费的PHP编辑器/开拓东西推荐
时间:2021-01-13
-
浅析iis7.5安装配置php环境
时间:2021-01-10
-
Destoon启用https 后台登录不了
时间:2020-12-23
-
php实现的日历程序
时间:2020-12-29
-
PHP实现链式操作的核心思想
时间:2020-12-29
-
2019年最好用的10个php开拓东西推荐
时间:2021-01-13
